package com.ruoyi.seedlingSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.seedlingSys.domain.Jiagong;
import com.ruoyi.seedlingSys.service.IJiagongService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加工管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/seedlingSys/jiagong")
public class JiagongController extends BaseController
{
    @Autowired
    private IJiagongService jiagongService;

    /**
     * 查询加工管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jiagong jiagong)
    {
        startPage();
        List<Jiagong> list = jiagongService.selectJiagongList(jiagong);
        return getDataTable(list);
    }

    /**
     * 导出加工管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:export')")
    @Log(title = "加工管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jiagong jiagong)
    {
        List<Jiagong> list = jiagongService.selectJiagongList(jiagong);
        ExcelUtil<Jiagong> util = new ExcelUtil<Jiagong>(Jiagong.class);
        util.exportExcel(response, list, "加工管理数据");
    }

    /**
     * 获取加工管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:query')")
    @GetMapping(value = "/{jiaGongID}")
    public AjaxResult getInfo(@PathVariable("jiaGongID") Long jiaGongID)
    {
        return success(jiagongService.selectJiagongByJiaGongID(jiaGongID));
    }

    /**
     * 新增加工管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:add')")
    @Log(title = "加工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jiagong jiagong)
    {
        return toAjax(jiagongService.insertJiagong(jiagong));
    }

    /**
     * 修改加工管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:edit')")
    @Log(title = "加工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jiagong jiagong)
    {
        return toAjax(jiagongService.updateJiagong(jiagong));
    }

    /**
     * 删除加工管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:jiagong:remove')")
    @Log(title = "加工管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jiaGongIDs}")
    public AjaxResult remove(@PathVariable Long[] jiaGongIDs)
    {
        return toAjax(jiagongService.deleteJiagongByJiaGongIDs(jiaGongIDs));
    }
}
